// Trade 模块小仓库
import { reqOrderInfo, submitOrder, reqPaymentInfo } from "@/api"

const state = {
  orderInfo: {},
}
const mutations = {
  GETORDERINFO(state, orderInfo) {
    state.orderInfo = orderInfo
  }
}
const actions = {
  // 获取订单数据
  async getOrderInfo({ commit }) {
    let { data: res } = await reqOrderInfo()
    if (res.code == 200) {
      commit('GETORDERINFO', res.data)
    }
  }
}

// 简化数据
const getters = {
  //  收件人信息
  userAddressList(state) {
    return state.orderInfo.userAddressList || []
  },
  // 订单详情信息
  detailArrayList(state) {
    return state.orderInfo.detailArrayList || []
  }
}

export default {
  state,
  mutations,
  actions,
  getters
}